class Solution:

    def __init__(self):
        self.a, self.b = 0, 1

    def __iter__(self):
        return self

    def __next__(self):
        self.a, self.b = self.b, self.a + self.b # 计算下一个值
        if self.a > 1000: # 退出循环的条件
            raise StopIteration();
        return self.a # 返回下一个值

    def Fibonacci(self, n):
        a = 0
        b = 1
        if(n==0):
            print(a)
        else:
            for i in n:
                a = b
                b = a + b
            print(b)

Solution().Fibonacci(1)
